<template>
  <el-card>
    <el-form :inline="true">
      <el-form-item label="一级分类">
        <el-select
          :disabled="scene == 0 ? true : false"
          v-model="CategoryStores.c1Id"
          @change="handler"
        >
          <el-option
            v-for="(c1, index) in CategoryStores.c1Arr"
            :key="c1.id"
            :index="index"
            :label="c1.name"
            :value="c1.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select
          :disabled="scene == 0 ? true : false"
          v-model="CategoryStores.c2Id"
          @change="handler1"
        >
          <el-option
            v-for="(c2, index) in CategoryStores.c2Arr"
            :key="c2.id"
            :index="index"
            :label="c2.name"
            :value="c2.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select
          :disabled="scene == 0 ? true : false"
          v-model="CategoryStores.c3Id"
        >
          <el-option
            v-for="(c3, index) in CategoryStores.c3Arr"
            :key="c3.id"
            :index="index"
            :label="c3.name"
            :value="c3.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>
<script setup lang="ts">
import { onMounted } from 'vue'
import Category from '@/stores/category'

let CategoryStores = Category()
defineProps(['scene'])

//组件挂在完毕
onMounted(async () => {
  await CategoryStores.getC1()
})
//以及下拉菜单的chaher
const handler = async () => {
  CategoryStores.c2Id = ''
  CategoryStores.c3Id = ''
  await CategoryStores.getC2()
  CategoryStores.c3Arr = []
}
const handler1 = async () => {
  CategoryStores.c3Id = ''
  await CategoryStores.getC3()
}
</script>
<style scoped lang="scss"></style>
